package com.lm.dynamic.controller;

import com.lm.dynamic.entry.SysUserEntity;
import com.lm.dynamic.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @GetMapping("/getUserByIntId")
    public SysUserEntity getUserByIntId(@RequestParam Long id) {
        return userService.getUserById(id);
    }

    @GetMapping("/insert")
    public SysUserEntity insert(@RequestParam Long id) {
        SysUserEntity sysUserEntity = new SysUserEntity();
        sysUserEntity.setEmail("admin@admin.com");
        sysUserEntity.setPassword("123456");
        sysUserEntity.setUsername("adminMaster");
        sysUserEntity.setCreateTime(new Date());
         userService.insertUser(sysUserEntity);
         return sysUserEntity;
    }
}
